package com.hotel.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.hotel.entity.Customer;
import com.hotel.service.CustomerService;

@Controller
public class CustomerController {
	@Autowired
	private CustomerService customerService;
	
	@RequestMapping(value="customerList")
	public ModelAndView AuthorityAllot(HttpServletRequest request,@RequestParam(value="pageNo",defaultValue="1")Integer pageNo,@RequestParam(value="pageSize",defaultValue="10")Integer pageSize){
		ModelAndView view = new ModelAndView();
		List<Customer> customers = customerService.findAllCustomer(pageNo, pageSize);
		view.addObject("customers", customers);
		view.addObject("pageNo", pageNo);
		view.addObject("pageSize", pageSize);
		view.setViewName("views/customer/customerList");
		return view;
	}
	
	@RequestMapping(value="findCustomerByzjNo")
	@ResponseBody
	public Customer findCustomerByzjNo(String zjNo){
		Customer customer = customerService.findCustomerByzjNo(zjNo);
		return customer;
	}
}
